package interaction;

import loadsave.LoadSaveable;
import loadsave.Memento;
import loadsave.loadsaveobject.LoadSaveObject;
import loadsave.loadsaveobject.LoadSaveObjectComposite;
import loadsave.loadsaveobject.LoadSavePrimitive;

public abstract class InteractionCommand implements LoadSaveable, Cloneable {

	private String msg;
	
	public InteractionCommand() {
		msg = null;
	}
	
	public InteractionCommand(String msg) {
		this.msg = msg;
	}
	
	/**
	 * getter for the text displayed on the choice
	 * @return
	 */
    public String getID() {
    	return msg;
    }
    
    /**
     * command method, will do whatever the given subclass is supposed to do
     */
    public abstract void execute();
    
	@Override
	public Memento getMemento() {
		return new Memento() {

			@Override
			public LoadSaveObject getState() {
				LoadSaveObjectComposite toReturn = new LoadSaveObjectComposite("", "InteractionCommand");
				toReturn.add("msg", new LoadSavePrimitive("msg", "String", msg));
				return toReturn;
			}

			@Override
			public void restoreState(LoadSaveObject lso) {
				msg = lso.get("msg").getValue();
			}
			
		};
	}
	
	@Override
	public abstract InteractionCommand clone();

}
